package com.food.dao.service;

import java.io.InputStream;
import java.sql.Date;
import java.util.List;

import com.food.dao.RecipeDAOJdbc;
import com.food.dao.in.RecipeDAO;
import com.food.model.Recipe;

public class RecipeService {
	private RecipeDAO dao = new RecipeDAOJdbc();
	public int insertRecipe(Recipe bean,InputStream is, int size) {
		int key=0;
		if(bean!=null) {
			key=dao.insertRecipe(bean,is,size);
		}
		return key;
	}
	public void updateRecipe(Recipe bean){
		if(bean!=null) {
			dao.updateRecipe(bean.getMbid(),bean.getRname(),bean.getCountryid(),
					bean.getRintroduce(),bean.getRtrick(),bean.getRimg(),bean.getRdate(),bean.getRid()) ;
		}
	}
	public void deleteRecipe(Recipe bean) {
		if(bean!=null) {
			dao.deleteRecipe(bean.getRid());
		}
	}
	public List<Recipe> findAllRecipe(){
		return dao.findAllRecipe();
	}
	public Recipe findRecipeById(Recipe bean){
		return dao.findRecipeById(bean.getRid());
	}
	public List<Recipe> findRecipeByName(Recipe bean){
		return dao.findRecipeByName(bean.getRname());
	}
	public List<Recipe> findRecipeByCountry(Recipe bean){
		return dao.findRecipeByCountry(bean.getCountryid());
	}
	public List< Recipe > findRecipeByMb (Recipe bean){
		return dao.findRecipeByMb(bean.getMbid());		
	}
	
    public List<Recipe> findAllRecipePages(int pagesize, int pageindex){
		return dao.findAllRecipePages(pagesize,pageindex);
	}	
	
    public List<Recipe> findTenNewRecipe(){
    	return dao.findTenNewRecipe();
    }
	
    public List<Recipe> findTopTenScore(){
    	return dao.findTopTenScore();
    }
	
	
}
